﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Api.Common
{
    public static class DateExtend
    {
        public static string ToStr(this DateTime date, string format = "yyyy-MM-dd")
        {
            return date.ToString(format);
        }
        public static string ToStr(this DateTime? date, string format = "yyyy-MM-dd")
        {
            if (date == null) return string.Empty;
            return date.Value.ToString(format);
        }

        public static string ToLongStr(this DateTime date, string format = "yyyy-MM-dd HH:MM:ss")
        {
            return date.ToString(format);
        }
        public static string ToLongStr(this DateTime? date, string format = "yyyy-MM-dd HH:MM:ss")
        {
            if (date == null) return string.Empty;
            return date.Value.ToString(format);
        }
    }
}
